﻿/* 维度端前端网整理 http://www.weiduduan.com */
var kEvent=(function(){

return {
	addEvent: function(element, name, observer, useCapture) {
		try{
			element=Dom.$id(element);
			if(element.addEventListener){
				if(name==='mouseenter')
					element.addEventListener('mouseover',withoutChildFunction(observer),useCapture);
				else if(name==='mouseleave')
				element.addEventListener('mouseout',withoutChildFunction(observer),useCapture);
				else
				//ele.addEventListener(type,func,false);
				element.addEventListener(name, observer, useCapture);
			}else if(element.attachEvent){
				element.attachEvent('on' + name, observer);
			}
		}catch(e){}
	}
}


})()

var Dom={
    $id:function(nodeId){
    	if(typeof nodeId=='string'){
    		return document.getElementById(nodeId);
    	}else if(typeof nodeId=='object'){
    		return nodeId;
    	}else{
			return false;
		}
    }

};

//单纯文字滚动start
function Textroll(divid){
	this.emId=divid+"Text";
	var obj=Dom.$id(this.emId);
	var objW=obj.offsetWidth;
	var timeID=null;
	obj.innerHTML = obj.innerHTML+obj.innerHTML;
	function funRoll(){
		var left=obj.style.left;
		if (isNaN(parseInt(left))) left=0;
		left=parseInt(left)-2;
		if(left<=-objW) left=0;
		obj.style.left = left+"px";
	}
	function funPlay(){
		timeId=setInterval(funRoll,110);
	}
	function funPause(){
		clearInterval(timeId);
	}
	this.inits=function(){
		funPlay();
		kEvent.addEvent(obj,"mouseenter",funPause);
		kEvent.addEvent(obj,"mouseleave",funPlay);
	}
	
}


/*页面调用*/
(new Textroll('ri')).inits();
/* 维度端前端网整理 http://www.weiduduan.com */